//mongo.module.ts
import { Module, Global } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { MongoService } from './mongo.service';
import { MusicList, MusicListSchema } from './schemas/musicList.schemas';
import { Room, RoomSchema } from './schemas/room.schemas';
@Global()
@Module({
  imports: [
    MongooseModule.forRootAsync({
      useFactory() {
        return {
          uri: `mongodb://localhost:27017`,
          user: 'root',
          pass: '123456',
          dbName: 'share-music',
          authSource: 'admin',
          retryDelay: 1000,
        };
      },
    }),
    MongooseModule.forFeature([
      { name: MusicList.name, schema: MusicListSchema },
      { name: Room.name, schema: RoomSchema },
    ]),
  ],
  providers: [MongoService],
  exports: [MongoService],
})
export class MongoModule {}
